﻿using ServiceCore;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

namespace Entity
{
    public class replenishment_record
    {
        /// <summary>
        /// 补货编号
        /// </summary>
        public string record_id { get; set; }
        /// <summary>
        /// 所属baseuserid
        /// </summary>
        public string baseuserid { get; set; }
        /// <summary>
        /// 操作人ID
        /// </summary>
        public string userid { get; set; }
        /// <summary>
        /// 补货人姓名 
        /// </summary>
        public string uname { get; set; }
        /// <summary>
        /// 机器名称 
        /// </summary>
        public string mch_name { get; set; }
        /// <summary>
        /// 机器ID
        /// </summary>
        public string mch_id { get; set; }
        /// <summary>
        /// 机器名称
        /// </summary>
        public string mch_sn { get; set; }
        public DateTime add_time { get; set; }

        public string remark { get; set; }
    }

    public class replenishment_record_details
    {
        [Description("disable")]
        /// <summary>
        /// 记录
        /// </summary>
        public string record_details_id { get; set; }
        [Description("disable")]
        /// <summary>
        /// 记录ID
        /// </summary>
        public string record_id { get; set; }
        [Description("货道号")]
        /// <summary>
        /// 补货货道
        /// </summary>
        public int slot_index { get; set; }
        [Description("disable")]
        /// <summary>
        /// 补货时间
        /// </summary>
        public DateTime record_time { get; set; }
        [Description("disable")]
        /// <summary>
        /// 商品ID
        /// </summary>
        public string product_id { get; set; }
        [Description("商品名称")]

        /// <summary>
        ///  商品名称
        /// </summary>
        public string product_name { get; set; }
        [Description("disable")]
        /// <summary>
        /// 商品图片
        /// </summary>
        public string product_pic { get; set; }
        [Description("最大库存")]
        /// <summary>
        /// 最大库存
        /// </summary>
        public int? max_count { get; set; }
        [Description("预警值")]
        /// <summary>
        /// 预警值
        /// </summary>
        public int? alert_value { get; set; }
        [Description("disable")]
        /// <summary>
        /// 减货数量
        /// </summary>
        public int reduce_count { get; set; }
        [Description("disable")]
        /// <summary>
        /// 加货数量
        /// </summary>
        public int plus_count { get; set; }
        [Description("补货前数量")]
        /// <summary>
        /// 补货前数量
        /// </summary>
        public int before_count { get; set; }
        [Description("补货后数量")]
        /// <summary>
        /// 补货后数量
        /// </summary>
        public int after_count { get; set; }
        [Description("补货数量")]
        /// <summary>
        /// 带正负的补货数量
        /// </summary>
        public int show_count { get; set; }
    }

    /// <summary>
    ///  用于出口参数的设定
    /// </summary>
    public class replenishment_record_out
    {
        public replenishment_record_out()
        {
            record = new replenishment_record();
            record_details = new List<replenishment_record_details>();
        }

        /// <summary>
        /// 记录
        /// </summary>
        public replenishment_record record { get; set; }
        /// <summary>
        /// 详情
        /// </summary>
        public List<replenishment_record_details> record_details { get; set; }
    }

    #region 业务定义
    public class out_of_stock_mch_search : Base_List_Params
    {
        /// <summary>
        /// 机器名称
        /// </summary>
        public string mchname { get; set; }

        public out_of_stock_mch_sort_func? sort_func { get; set; }
    }
    /// <summary>
    /// 定义排序方式枚举
    /// </summary>
    public enum out_of_stock_mch_sort_func
    {
        缺货货道数正序 = 0,
        缺货货道数倒序 = 1,
        缺货总数正序 = 3,
        缺货总数倒序 = 4,
        达到预警货道数正序 = 5,
        达到预警货道数倒序 = 6
    }

    public class out_of_stock_mch_item
    {
        [Description("disable")]
        /// <summary>
        /// 机器ID
        /// </summary>
        public string mch_id { get; set; }
        [Description("机器名称")]
        /// <summary>
        /// 机器名称
        /// </summary>
        public string mch_name { get; set; }
        [Description("最大库存")]
        /// <summary>
        /// 最大库存
        /// </summary>
        public int max_stock_count { get; set; }
        [Description("当前库存")]
        /// <summary>
        /// 当前库存
        /// </summary>
        public int now_stock_count { get; set; }
        [Description("缺货总数")]
        /// <summary>
        /// 缺货总数
        /// </summary>
        public int out_of_stock_count { get; set; }
        [Description("缺货百分比")]
        /// <summary>
        /// 缺货百分比 out_of_stock_count/max_stock_count
        /// </summary>
        public string out_of_stock_rate
        {
            get
            {
                decimal rate = 0;
                if (max_stock_count != 0)
                {
                    rate = out_of_stock_count / Convert.ToDecimal(max_stock_count) * 100;
                }
                return rate.ToString("0.00") + "%";
            }
        }
        [Description("货道总数")]
        /// <summary>
        /// 货道总数
        /// </summary>
        public int slot_count { get; set; }
        [Description("缺货货道数")]
        /// <summary>
        /// 缺货货道数
        /// </summary>
        public int out_of_stock_slot_count { get; set; }
        [Description("货道百分比")]
        /// <summary>
        /// 货道百分比  out_of_stock_slot_count/slot_count
        /// </summary>
        public string out_of_stock_slot_rate
        {
            get
            {
                decimal rate = 0;
                if (slot_count != 0)
                {
                    rate = out_of_stock_slot_count / Convert.ToDecimal(slot_count) * 100;
                }
                return rate.ToString("0.00") + "%";
            }
        }
        [Description("达到预警值的数量")]
        /// <summary>
        /// 达到预警值的数量
        /// </summary>
        public int need_alert_count { get; set; }
        [Description("预警百分比")]
        /// <summary>
        /// 预警百分比  need_alert_count/slot_count
        /// </summary>
        public string need_alert_rate
        {
            get
            {
                decimal rate = 0;
                if (need_alert_count != 0)
                {
                    rate = need_alert_count / Convert.ToDecimal(slot_count) * 100;
                }
                return rate.ToString("0.00") + "%";
            }
        }
    }



    public class get_out_of_stock_detials_query : Base_List_Params
    {
        /// <summary>
        /// 机器ID
        /// </summary>
        public string mch_id { get; set; }
        /// <summary>
        /// 搜索项
        /// </summary>
        public search_details_enum? searchtype { get; set; } = search_details_enum.全部货道;
        /// <summary>
        /// 商品名称
        /// </summary>
        public string product_name { get; set; }
    }
    public enum search_details_enum
    {
        全部货道 = 0,
        只看达到预警值货道 = 1,
        只看缺货货道 = 2,
    }
    public class get_out_of_stock_details_item
    {
        [Description("disable")]
        /// <summary>
        /// 货道ID
        /// </summary>
        public string Id { get; set; }
        [Description("货道号")]
        /// <summary>
        /// 货道
        /// </summary>
        public int index { get; set; }
        [Description("货道商品")]
        /// <summary>
        ///  商品名称
        /// </summary>
        public string productname { get; set; } 
        [Description("最大库存")]
        /// <summary>
        /// 最大库存
        /// </summary>
        public int maxcount { get; set; }
        [Description("disable")]
        /// <summary>
        ///  商品ID
        /// </summary>
        public string productid { get; set; }
        [Description("预警值")]
        /// <summary>
        /// 预警值
        /// </summary>
        public int ShortageThreshold { get; set; }
        [Description("当前库存")]
        /// <summary>
        /// 货道库存
        /// </summary>
        public int count { get; set; }
        [Description("缺货数量")]
        /// <summary>
        /// 缺货库存
        /// </summary>
        public int out_of_stock_count
        {
            get
            {
                return maxcount - count;
            }
        }
    }





    public class replenishment_record_list_item
    {
        /// <summary>
        /// 补货ID
        /// </summary>
        public string  record_id { get; set; }
        /// <summary>
        /// 补货时间
        /// </summary>
        public DateTime add_time { get; set; }
        /// <summary>
        /// 补货账号
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// 员工姓名
        /// </summary>
        public string uname { get; set; }
        /// <summary>
        /// 机器名称
        /// </summary>
        public string mch_name { get; set; }
        /// <summary>
        /// 减货数量
        /// </summary>
        public int total_reduce_count { get; set; }
        /// <summary>
        /// 补货数量
        /// </summary>
        public int total_plus_count { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string remark { get; set; }

    }

    public class replenishment_record_query : Base_List_Params
    {
        /// <summary>
        /// 账号ID
        /// </summary>
        public string userid { get; set; }
        /// <summary>
        /// 机器名称
        /// </summary>
        public string mch_name { get; set; }
        /// <summary>
        /// 开始时间
        /// </summary>
        public string start_time { get; set; }
        /// <summary>
        /// 结束时间
        /// </summary>
        public string end_time { get; set; }
    }


    public class replenishment_record_details_query : Base_List_Params
    {
        /// <summary>
        /// 对应补货记录ID
        /// </summary>
        public string record_id { get; set; }
        /// <summary>
        /// 搜索类型
        /// </summary>
        public search_record_details_enum? searchtype { get; set; }
        /// <summary>
        /// 商品名称查询
        /// </summary>
        public string product_name { get; set; }
    }
    public enum search_record_details_enum
    {
        全部 = 0,
        只看增加库存 = 1,
        只看减少库存 = 2,
    }
    #endregion
}
